﻿Imports System.Reflection

''' <summary>
''' 属性読み込みクラス
''' </summary>
''' <remarks></remarks>
Public Class AttributeReader

    ''' <summary>
    ''' クラス属性を取得します
    ''' </summary>
    ''' <typeparam name="T">取得したい属性</typeparam>
    ''' <param name="target">検索対象となるクラスの型</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function Read(Of T)(ByVal target As Type) As IEnumerable(Of T)
        Return (From el As T In target.GetCustomAttributes(GetType(T), False))
    End Function

    ''' <summary>
    ''' プロパティ属性を取得します
    ''' </summary>
    ''' <typeparam name="T">取得したい属性</typeparam>
    ''' <param name="target">検索対象となるプロパティ</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function Read(Of T)(ByVal target As PropertyInfo) As IEnumerable(Of T)
        Return (From el As T In target.GetCustomAttributes(GetType(T), False))
    End Function

End Class
